﻿using NearAop;
using System;
using System.Collections.Generic;
using System.Text;

namespace CS
{
    [AddProxyMethod(typeof(Proxy3), HandlerName = "自定义函数")]
    class T06_方法代理_指定处理函数名称
    {
        //实例函数
        public void SetValue1(int value) { }

        //静态函数
        public static void SetValue2(int value) { }
    }


    class Proxy3
    {
        public void 自定义函数(MethodArgs methodArgs)
        {
            var info = methodArgs.MethodInfo;
            var staticStr = info.IsStatic ? "静态" : "";
            Console.WriteLine($"进入{staticStr}函数[{info.DeclaringType}.{info.Name}]");
        }

        public TResult 自定义函数<TResult>(MethodArgs methodArgs, TResult result)
        {
            var info = methodArgs.MethodInfo;
            var staticStr = info.IsStatic ? "静态" : "";
            Console.WriteLine($"退出{staticStr}函数[{info.DeclaringType}.{info.Name}]");
            return result;
        }
    }
}
